<template>
  <div>
    <a-card>
      <a-row style="margin-bottom: 10px">
        <a-col :span="24"  style="display: flex;flex-direction: row-reverse">
          <a-button v-print="'#printReport'" type="primary">打印报表</a-button>
        </a-col>
      </a-row>
      <div id="printReport">
        <table border="1" cellpadding="4" cellspacing="0" bordercolor="#000" style="width: 100%">
          <tr>
            <th colspan="22">
              <div style="position: relative;text-align: center">
                <span>{{reportData.title}}</span>
<!--                <span style="position: absolute;right: 0px;top:0px">2021年5月</span>-->
              </div>
            </th>
          </tr>
          <tr>
            <td colspan="22">
              <a-row>
                <a-col :span="12">线别:{{reportData.title}}</a-col>
                <a-col :span="12" style="text-align: right">
                  {{ reportData.createTime }}
                </a-col>
              </a-row>
            </td>
          </tr>
          <tr  v-if="reportData.dayCheckName.length > 0">
            <td>一.开线前必须确认项目 (由带线技术员填写)</td>
            <td colspan="12">白班</td>
            <td colspan="9">夜班</td>
          </tr>
          <tr v-for="(item,index) in reportData.dayCheckName" v-if="reportData.dayCheckName.length > 0">
            <td style="width: 200px;">{{index + 1+'.'+item}}</td>
            <td colspan="12">{{reportData.dayCheckList[index][0].inspectionResults}}</td>
            <td colspan="9">{{reportData.dayCheckList[index][1].inspectionResults}}</td>
          </tr>
          <tr v-if="reportData.dayCheckName.length > 0">
            <td>带线技术员签名</td>
            <td colspan="12">{{reportData.dayCheckList[0][0].maintainer}}</td>
            <td colspan="9">{{reportData.dayCheckList[0][1].maintainer}}</td>
          </tr>
          <tr v-if="reportData.weekCheckList.length > 0">
            <td rowspan="2">二.生产过程必须确认项目 (由作业员填写)</td>
            <td colspan="2" v-for="i in 10">{{ 'Zone' + i }}</td>
            <td rowspan="2">C/V Speed</td>
          </tr>
          <tr v-if="reportData.weekCheckList.length > 0">
            <td v-for="i in 20" style="height: 30px">{{i%2 === 0 ? 'Low':'Up'}}</td>
          </tr>
          <tr v-for="(item,index) in reportData.weekCheckName" v-if="reportData.weekCheckList.length > 0">
            <td>{{ index+1 }}.{{ item }}</td>
            <td v-for="i in 20">{{i%2 === 0 ? white[index][i-1].inspectionResults : white[index][i-1].measureStandard}}</td>
            <td style="text-align: right">cm/min</td>
          </tr>
          <tr v-if="reportData.weekCheckList.length > 0">
            <td>日班作业员签名</td>
            <td colspan="21">{{white[0][0].maintainer}}</td>
          </tr>
          <tr v-for="(item,index) in reportData.weekCheckName" v-if="reportData.weekCheckList.length > 0">
            <td>{{ index+1 }}.{{ item }}</td>
            <td v-for="i in 20">{{i%2 === 0 ? black[index][i-1].inspectionResults : black[index][i-1].measureStandard}}</td>
            <td style="text-align: right">cm/min</td>
          </tr>
          <tr v-if="reportData.weekCheckList.length > 0">
            <td>夜班作业员签名</td>
            <td colspan="21">{{black[0][0].maintainer}}</td>
          </tr>
          <tr>
            <td colspan="8">
              <a-row>
                <a-col :span="24" style="text-align: center">异常现象</a-col>
              </a-row>
              <a-row>
                <a-col :span="24" style="height: 100px">
                  {{reportData.inspectionMethod}}
                </a-col>
              </a-row>
            </td>
            <td colspan="14">
              <a-row>
                <a-col :span="24" style="text-align: center">改善对策</a-col>
              </a-row>
              <a-row>
                <a-col :span="24" style="height: 100px">
                  {{reportData.inspectionCycle}}
                </a-col>
              </a-row>
            </td>
          </tr>
          <tr>
            <td colspan="8">工程师：{{reportData.query1}}</td>
            <td colspan="14">生产主管：{{reportData.reviewer}}</td>
          </tr>
          <tr>
            <td colspan="22">编号：{{ reportData.documentNumber }}     版本 :1    保密等级：一般   使用形式：纸质档   保存期限 :2年     销毁方式：双面使用</td>
          </tr>
        </table>
      </div>
    </a-card>
  </div>
</template>

<script>
export default {
  /** SMT回焊炉作业记录表 **/
  name: 'SMTRewindFurnaceOperationRecord',
  props:{
    reportData:{
      type:Object,
      default:()=>{}
    },
    type:{
      type:String,
      default:''
    }
  },
  watch:{
    reportData:{
      handler(newVal){
        this.chaifen()
      },
      deep:true,
      immediate:true,
    }
  },
  data(){
    return {
      checkList:[
        {
          checkName:'生产机型',
          location:'1'
        },
        {
          checkName:'程式名称',
          location:'2'
        },
      ],
      white:[],
      black:[]
    }
  },
  methods:{
    chaifen(){
      this.white = []
      this.black = []
      this.reportData.weekCheckList.forEach((item,i)=>{
        this.white.push([])
        this.black.push([])
        item.forEach((filed,index)=>{
          if ([0,2,4,6,8,10,12,14,16,18].indexOf(index) > -1){
            this.white[i].push(filed)
            this.white[i].push(filed)
          }else{
            this.black[i].push(filed)
            this.black[i].push(filed)
          }
        })
      })
      console.log(1111,this.white,this.black)
    },
  }

}
</script>

<style scoped>

</style>